package com.xw.childhealth.converter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xw.childhealth.VO.Response2EntityBeanVO;
import com.xw.childhealth.enums.ResultEnum;
import com.xw.childhealth.exception.ChildHealthException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description:
 * @Author: y
 * @CreateDate: 2019-11-18 08:43
 * @Version: 1.0
 */
@Data
@Slf4j
public class Response2Entity {

    public static Response2EntityBeanVO convert(String str) {
        Gson gson = new Gson();
        Response2EntityBeanVO bean = new Response2EntityBeanVO();
        try {
            bean = gson.fromJson(str, new TypeToken<Response2EntityBeanVO>() {
            }.getType());
        } catch (Exception e) {
            log.error("[对象转换错误] str  :{}", str);
            throw new ChildHealthException(ResultEnum.OBJECT_TRAN_ERROR);
        }
        return bean;
    }


}
